import api from '../plugins/axios'

// 认证相关的API
export const authAPI = {
  // 用户登录
  login(username,password) {
    const formData = new FormData()
    formData.append('username',username)
    formData.append('password',password)
    return api.post('/auth/login',formData,{
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    })
  },

  // 获取当前用户信息
  getCurrentUser() {
    return api.get('/auth/me')
  }
}

// 权限相关的API
export const permissionAPI = {
  // 获取用户菜单
  getUserMenus() {
    return api.get('/permissions/menus')
  },

  // 检查权限
  checkPermission(permissionCode) {
    return api.get(`/permissions/check?permission_code=${permissionCode}`)
  }
}


// 仪表板相关API
export const dashboardAPI = {
  // 获取统计数据
  getStatistics() {
    return api.get('/dashboard/statistics')
  },

  // 获取图表数据
  getChartData(chartType) {
    return api.get(`/dashboard/charts/data?chart_type=${chartType}`)
  }
}

export default api
